home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Tk / win / tkWinPixmap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-08  |  2.8 KB  |  130 lines

  1. /* 
  2.  * tkWinPixmap.c --
  3.  *
  4.  *    This file contains the Xlib emulation functions pertaining to
  5.  *    creating and destroying pixmaps.
  6.  *
  7.  * Copyright (c) 1995 Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  * SCCS: @(#) tkWinPixmap.c 1.13 96/03/01 17:44:04
  13.  */
  14.  
  15. #include "tkWinInt.h"
  16.  
  17.  
  18. /*
  19.  *----------------------------------------------------------------------
  20.  *
  21.  * XCreatePixmap --
  22.  *
  23.  *    Creates an in memory drawing surface.
  24.  *
  25.  * Results:
  26.  *    Returns a handle to a new pixmap.
  27.  *
  28.  * Side effects:
  29.  *    Allocates a new Win32 bitmap.
  30.  *
  31.  *----------------------------------------------------------------------
  32.  */
  33.  
  34. Pixmap
  35. XCreatePixmap(display, d, width, height, depth)
  36.     Display* display;
  37.     Drawable d;
  38.     unsigned int width;
  39.     unsigned int height;
  40.     unsigned int depth;
  41. {
  42.     TkWinDrawable *newTwdPtr, *twdPtr;
  43.     
  44.     display->request++;
  45.  
  46.     newTwdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable));
  47.     if (newTwdPtr == NULL) {
  48.     return None;
  49.     }
  50.     newTwdPtr->type = TWD_BITMAP;
  51.     newTwdPtr->bitmap.depth = depth;
  52.     twdPtr = (TkWinDrawable *)d;
  53.     if (twdPtr->type != TWD_BITMAP) {
  54.     if (twdPtr->window.winPtr == NULL) {
  55.         newTwdPtr->bitmap.colormap = DefaultColormap(display,
  56.             DefaultScreen(display));
  57.     } else {
  58.         newTwdPtr->bitmap.colormap = twdPtr->window.winPtr->atts.colormap;
  59.     }
  60.     } else {
  61.     newTwdPtr->bitmap.colormap = twdPtr->bitmap.colormap;
  62.     }
  63.     newTwdPtr->bitmap.handle = CreateBitmap(width, height, 1, depth, NULL);
  64.  
  65.     if (newTwdPtr->bitmap.handle == NULL) {
  66.     ckfree((char *) newTwdPtr);
  67.     return (Pixmap)NULL;
  68.     }
  69.     
  70.     return (Pixmap)newTwdPtr;
  71. }
  72.  
  73. /*
  74.  *----------------------------------------------------------------------
  75.  *
  76.  * XFreePixmap --
  77.  *
  78.  *    Release the resources associated with a pixmap.
  79.  *
  80.  * Results:
  81.  *    None.
  82.  *
  83.  * Side effects:
  84.  *    Deletes the bitmap created by XCreatePixmap.
  85.  *
  86.  *----------------------------------------------------------------------
  87.  */
  88.  
  89. void
  90. XFreePixmap(display, pixmap)
  91.     Display* display;
  92.     Pixmap pixmap;
  93. {
  94.     TkWinDrawable *twdPtr = (TkWinDrawable *) pixmap;
  95.  
  96.     display->request++;
  97.     if (twdPtr != NULL) {
  98.     DeleteObject(twdPtr->bitmap.handle);
  99.     ckfree((char *)twdPtr);
  100.     }
  101. }
  102.  
  103. /*
  104.  *----------------------------------------------------------------------
  105.  *
  106.  * TkSetPixmapColormap --
  107.  *
  108.  *    The following function is a hack used by the photo widget to
  109.  *    explicitly set the colormap slot of a Pixmap.
  110.  *
  111.  * Results:
  112.  *    None.
  113.  *
  114.  * Side effects:
  115.  *    None.
  116.  *
  117.  *----------------------------------------------------------------------
  118.  */
  119.  
  120. void
  121. TkSetPixmapColormap(pixmap, colormap)
  122.     Pixmap pixmap;
  123.     Colormap colormap;
  124. {
  125.     TkWinDrawable *twdPtr = (TkWinDrawable *)pixmap;
  126.     twdPtr->bitmap.colormap = colormap;
  127. }
  128.  
  129.  
  130.